<?php

/* $Revision: 1.38 $ */
	// Titles and screen header
	// Needs the file config.php loaded where the variables are defined for
	//  $rootpath
	//  $title - should be defined in the page this file is included with

	/*The module link codes are hard coded in a switch statement below to determine the options to show for each tab */
	$ModuleLink = array('orders', 'AR', 'AP', 'PO', 'stock', 'manuf', 'GL', 'system');
	/*The headings showing on the tabs accross the main index used also in WWW_Users for defining what should be visible to the user */
	$ModuleList = array(_('Sales'), _('Receivables'), _('Payables'), _('Purchases'), _('Inventory'), _('Manufacturing'), _('General Ledger'), _('Setup'));	
	
	if (!headers_sent()){
		//header('Content-type: text/html; charset=' . _('iso-8859-1'));
		header('Content-type: text/html; charset=' . _('utf8'));
	}
	echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
			"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';


	echo '<html xmlns="http://www.w3.org/1999/xhtml"><head><title>' . $title . '</title>';
	echo '<link rel="shortcut icon" href="'. $rootpath.'/favicon.ico" />';
	echo '<link rel="icon" href="' . $rootpath.'/favicon.ico" />';
	echo '<meta http-equiv="Content-Type" content="text/html; charset=' . _('utf8') . '" />';
	echo '<link href="'.$rootpath. '/css/'. $_SESSION['Theme'] .'/default.css" rel="stylesheet" type="text/css" />';
	echo '<script type="text/javascript" src = "'.$rootpath.'/javascripts/MiscFunctions.js"></script>';
	echo '</head>';

	echo '<body>';

	$_SESSION['WikiRoot'] = 'http://localhost/wiki';
	if ($title AND substr($title,0,4) != 'Help') {
		echo '<table cellpadding="0" cellspacing="0" border="0" id="quick_menu" class="quick_menu">';
		echo '<tr>';
		echo '<td align="left" style="width:100%;" class="quick_menu_left">';
		echo _('Company'). ': ' . stripslashes($_SESSION['CompanyRecord']['coyname']) . ' - <a href="' .  $rootpath . '/UserSettings.php?' . SID . '">' . _('User name') . ': ' . stripslashes($_SESSION['UsersRealName']) . '</a>';
		echo '<br />' . $title . '</td>';

		echo '<td class="quick_menu_tabs">';
		echo '<table cellpadding="0" cellspacing="0" class="quick_menu_tabs"><tr>';
		echo '<td class="quick_menu_tab" align="center"><a accesskey="1" href="' .  $rootpath . '/A_SalesHome.php?' . SID . '"><span style="text-decoration:underline;">1</span> ' . _('Sales') . '</a></td>';

		if (count($_SESSION['AllowedPageSecurityTokens'])>1){

			echo '<td class="quick_menu_tab" align="center"><a accesskey="2" href="' .  $rootpath . '/SelectCustomer.php?' . SID . '"><span style="text-decoration:underline;">2</span> ' . _('Customers') . '</a></td>';
			echo '<td class="quick_menu_tab" align="center"><a accesskey="3" href="' .  $rootpath . '/SelectProduct.php?' . SID . '"><span style="text-decoration:underline;">3</span> ' . _('Items') . '</a></td>';
			echo '<td class="quick_menu_tab" align="center"><a accesskey="4" href="' .  $rootpath . '/SelectSupplier.php?' . SID . '"><span style="text-decoration:underline;">4</span> ' . _('Suppliers') . '</a></td>';
			echo '<td class="quick_menu_tab" align="center"><a accesskey="5" href="' .  $rootpath . '/A_ManufHome.php?' . SID . '"><span style="text-decoration:underline;">4</span> ' . _('Manuf') . '</a></td>';

		}

		echo '<td class="quick_menu_tab" align="center"><a accesskey="0" href="' . $rootpath . '/Logout.php?' . SID . '" onclick="return confirm(\'' . _('Are you sure you wish to logout?') . '\');"><span style="text-decoration:underline;">0</span> '  . _('Logout') . '</a></td>';

		echo '</tr></table>';
		echo '</td></tr>';
		echo '<tr>';
		
	if (count($_SESSION['AllowedPageSecurityTokens'])!=1){
	  /* Security settings DO allow seeing the main menu */
		$i=0;
		while ($i < count($ModuleLink)){

			// This determines if the user has display access to the module see config.php and header.inc
			// for the authorisation and security code
			if ($_SESSION['ModulesEnabled'][$i]==1)	{

				// If this is the first time the application is loaded then it is possible that
				// SESSION['Module'] is not set if so set it to the first module that is enabled for the user
				if (!isset($_SESSION['Module'])OR $_SESSION['Module']==''){
					$_SESSION['Module']=$ModuleLink[$i];
				}
				if ($ModuleLink[$i] == $_SESSION['Module']){
					echo "<td class='main_menu_selected'><A HREF='". $_SERVER['PHP_SELF'] .'?'. SID . '&Application='. $ModuleLink[$i] ."'>". $ModuleList[$i] .'</A></td>';
				} else {
					echo "<td class='main_menu_unselected'><A HREF='". $_SERVER['PHP_SELF'] .'?'. SID . '&Application='. $ModuleLink[$i] ."'>". $ModuleList[$i] .'</A></td>';
				}
			}
			$i++;
		}
	}

	echo '</tr></table>';

	echo '</td>';
	echo '</tr>';
	echo '</table>';
	//echo '<table><td>Shoutcuts</td>  <td>';

?>